/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lottoapp;

import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.ElementList;

/**
 *
 * @author Mark
 */
public class LottoResult {
    @Attribute(required=false)
    private String title;
    @ElementList
    private Set<Integer> numbers;

    public LottoResult() {
    }

    
    private LottoResult(String title,Set<Integer>numbers){
        this.title =title;
        this.numbers = numbers;
    };
    public static LottoResult createWithDateAndNumbers(String title, Set<Integer> numbers) {
        LottoResult result = new LottoResult(title,numbers);
        return result;
    }

    public String getTitle() {
        return title;
    }

    public Set<Integer> getNumbers() {
        return Collections.unmodifiableSet(numbers);
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 17 * hash + Objects.hashCode(this.title);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final LottoResult other = (LottoResult) obj;
        if (!Objects.equals(this.title, other.title)) {
            return false;
        }
        if (!Objects.equals(this.numbers, other.numbers)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        StringBuilder numbersBuilder = new StringBuilder();
        for(int nr: numbers){
            numbersBuilder.append(" ");
            numbersBuilder.append(nr);
        }
        return getTitle()+":"+numbersBuilder.toString();
    }
    
}
